/* Copyright 2008. All rights reserved. */
package org.bling.util;

import java.util.Properties;

import org.bling.parser.BlingParserException;
import org.bling.process.BlingProcessingException;
import org.bling.process.Request;
import org.bling.process.RequestProcessor;
import org.bling.process.context.ApplicationContext;
import org.bling.process.render.BlingRenderException;
import org.eclipse.swt.widgets.Display;
import org.gorm.orm.GormStandalone;

/**
 * 
 * <code>BlingMain</code> is the object used by Bling applications
 * to launch the application.
 * 
 * it is responsible for initializing the database, and configuring
 * the request processor, and rendering the splash screen.
 * 
 * @author DISBROB
 * 
 */
public class BlingMain {

	private static void initializeGorm() {
		Properties props = PropertyLoader
				.loadProperties("database.properties");
	
		GormStandalone gsm = GormStandalone.getInstance(props);
		
	}

	public static void main(String args[]) throws BlingProcessingException,
			BlingParserException, BlingRenderException {
		Properties boot = PropertyLoader.loadProperties("boot.properties");

		initializeGorm();

		String splash = boot.getProperty("splash");
		Request request = new Request(splash);

		ApplicationContext context = ApplicationContext.getInstance();
		RequestProcessor rp = new RequestProcessor();
		context.setAttribute(
				Constants.ApplicationContextAttributes.REQUEST_PROCESSOR, rp);

		Display display = new Display();
		context.setAttribute(Constants.ApplicationContextAttributes.DISPLAY,
				display);

		rp.process(request);
	}

}
